#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <cstdlib>
//#include "config.h"
#include <time.h>
#include <iostream>
using namespace std;
//this is a load generator writing argv[1] messages per second into the test.hb file in argv[2] seconds (-1 forever)
int main(int argc, char*argv[]) {
  int rate = atoi(argv[1]);
  int duration = 1000000/rate;
  printf("duration %d\n", duration); 
  char *impression_file = "/root/flume/cheng/testlogs/test.hb";
  while(1){ 
    FILE *iptr = fopen(impression_file, "a+");
    srand((unsigned)time(0));
    int ran = random()%25535;
    //printf("%d - frank [10/Oct/2000-13-55-36 -0700] \"GET /apache_pb.gif HTTP/1.0\" :versascope\n", ran);
    fprintf(iptr, "%d - frank [10/Oct/2000-13-55-36 -0700] \"GET /apache_pb.gif HTTP/1.0\" :versascope\n", ran);
    usleep(duration); 
    fclose(iptr);
  }
}
